<?php 
//session_start();

include_once '../classeBDD/connectBdd.php';
$sql = sql::connect();
$memePage =$_SERVER["PHP_SELF"];
/*if(isset($_GET['param'])||isset($_GET['modifier'])){
    include_once '../classeBDD/connectBdd.php';
    include_once"../commune/Entet.php";
    include_once"../commune/contenu.php";
}*/
if(isset($_GET['param'])){
$donners= explode(';',$_GET['param']);
       for($i = 0; $i < sizeof($donners); ++$i){
          $table[strstr($donners[$i], '=', true)]=substr(strstr($donners[$i], '='),1);
    }}
    
$message = 'Enter your login and your password';
if (isset($_POST['btnConnexion']) && !empty($_POST['email']) && !empty($_POST['password'])) {	
        $query = 'SELECT * FROM `user` WHERE  `mail` = "'.$_POST['email'].'" AND `mod_passe` = "'.MD5($_POST['password']).'" ;';
        $query = $sql->query($query );
	if ($sql->num_rows($query)==0) {
		$message = '<span class="txtRouge12b">Connexion failed !</span>';
	}
	else {  
           
	    $_SESSION['user'] = $_POST['email'];
           
            if(isset ($_GET['param'])){ 
               echo '<script language="Javascript">document.location.replace("./index.php?page_id=action_annonce&param='.$_GET['param'].'");</script>';
            }else{ if(isset($_GET['modifier'])){
                   echo '<script language="Javascript">document.location.replace("./index.php?page_id=Modifier_Annonces");</script>';
            }else{ echo '<script language="Javascript">document.location.replace("./");</script>';}
            }
            die;
		
	}
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title>Jquery Inline Form Validation Engine</title>
		<link rel="stylesheet" href="/css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
		<link rel="stylesheet" href="/css/template.css" type="text/css" media="screen" title="no title" charset="utf-8" />
		<script src="/jquery/jquery.min.js" type="text/javascript"></script>
		<script src="/jquery/jquery.validationEngine-en.js" type="text/javascript"></script>
		<script src="/jquery/jquery.validationEngine.js" type="text/javascript"></script>

		<!-- AJAX SUCCESS TEST FONCTION	
			<script>function callSuccessFunction(){alert("success executed")}
					function callFailFunction(){alert("fail executed")}
			</script>
		-->
		
		<script>	
		$(document).ready(function() {

			
			$("#formID").validationEngine()
		
			
			//$.validationEngine.loadValidation("#date")
			//alert($("#formID").validationEngine({returnIsValid:true}))
			//$.validationEngine.buildPrompt("#date","This is an example","error")	 		 // Exterior prompt build example
			//$.validationEngine.closePrompt(".formError",true) 							// CLOSE ALL OPEN PROMPTS
		});
		
		// JUST AN EXAMPLE OF CUSTOM VALIDATI0N FUNCTIONS : funcCall[validate2fields]
		function validate2fields(){
			if($("#firstname").val() =="" ||  $("#lastname").val() == ""){
				return false;
			}else{
				return true;
			}
		}
	</script>	
<title>Document sans titre</title>
</head>
<body>
    <form  class="formular" method="post" action="" id="formID" enctype="multipart/form-data">
        <fieldset>
            <legend>Identification </legend>
            <fieldset>
                 <legend><?php echo $message;?></legend>
                 <span>Email<br/></span><label><input value="<?php if(isset($_POST['email'])) echo $_POST['email']; else if(isset ($table['mail']))echo $table['mail'];?>"  class="validate[required,custom[email]] text-input" type="text" name="email" id="email" /><br/></label>
                <label>
		  <span>Password : </span>
		  <input value=""  class="validate[required,length[6,11]] text-input" type="password" name="password"  id="password" />
	        </label>
            </fieldset>
              <span><input name="btnConnexion" type="submit" id="btnConnexion" value="Connexion" /></span>
            
            &nbsp;&nbsp;&nbsp;&nbsp;<br/>
            <span><a href="./index.php?page_id=Ajouter_user&param=<?php if(isset($_GET['param']))echo $_GET['param'];?>">creer votre compter</a></span>
              
        </fieldset>
        
    </form>
</body>
</html>

 
<?php //include_once"../commune/pied.php";?>
